import http from "@/utils/request/httpRequest";
import type { ListPagination, ListType } from "@/types/commonType.ts";
import type {
    newsListType,
    newsAddType,
    newsEditType,
    newsCenterEditType,
    newsCenterAddType,  
    newsHelpEditType,
    newsHelpAddType,
    getPushCountType, PushListDataType
} from "@/types/newsType"
import outHttp from "@/utils/request/httpOutRequest.ts";

// 查询
export const getNewsList = (params: ListPagination & {
    type: string
}) => http.get<ListType<newsListType[]>>(`compt/site-match-news/list?type=${params.type}&current=${params.current}&size=${params.size}`)

// 添加
export const addNews = (data: newsAddType) => http.post("compt/site-match-news/add", data)

// 编辑
export const editNews = (data: newsEditType) => http.post("compt/site-match-news/update", data)

// 删除
export const delNews = (id: string) => http.post(`compt/site-match-news/delete/${id}`)

// 赛事中心
export const newsCenterList = (data: ListPagination & {
    title: string
}) => http.post<ListType<newsCenterEditType[]>>("compt/site-match/list", data)

// 添加
export const newsCenterAdd = (data: newsCenterAddType) => http.post("compt/site-match/add", data)
// 编辑
export const newsCenterEdit = (data: newsCenterEditType) => http.post("compt/site-match/update", data)

// 删除
export const newsCenterDel = (data: string[]) => http.post("compt/site-match/delete", data)
// 置顶
export const newsCenterTop = (data: string[]) => http.post("compt/site-match/toTop", data)

// 帮助中心
export const newsHelpList = (params: ListPagination) => http.get<ListType<newsHelpEditType[]>>(`help-center/list`, { params })
// 添加
export const newsHelpAdd = (data: newsHelpAddType) => http.post("help-center/save", data)
// 编辑
export const newsHelpEdit = (data: newsHelpAddType) => http.post("help-center/update", data)
// 删除
export const newsHelpDel = (id: string) => http.post("help-center/delete", { id })


// 报名中心
export const getRegistrationList = (data) => http.get(`regist/listRegister`, {
    params: data
})
// 项目申报书
export const getDeclaration = (query) => http.get("registDeclaration/getByUid", { params: query })
export const getDeclarationOut = (query) => outHttp.get("registDeclaration/getByUid", { params: query })
// 单位
export const getRegistUnit = (query) => http.get("registUnit/getByUid", { params: query })
export const getRegistUnitOut = (query) => outHttp.get("registUnit/getByUid", { params: query })
export const selectListAll = () => http.get('sys/dict/listAll')
export const selectListAllOut = () => outHttp.get('sys/dict/listAll')
// 省市下拉列表
export const listProvince = () => http.get('sys/province/listProvince')

export const registProjectBasicInfoGetByUid = (query) => http.get("registProjectBasicInfo/getByUid", { params: query })
export const registProjectBasicInfoGetByUidOut = (query) => outHttp.get("registProjectBasicInfo/getByUid", { params: query })
export const listRacetrack = () => http.get('sys/dict/listRacetrack')
// 常规赛道下拉列表
export const listNormalRacetrack = () => http.get('sys/dict/listNormalRacetrack')

// 导出 regist/exportXls
export const exportXls = (data: any) => http.getUpload("regist/exportSummary", data)
// 导出初赛
export const exportSummaryXls = () => http.getUpload("regist/exportSummaryXls")

// 下载 regist/downPdf
export const downPdf = (registUid: string) => http.getUpload("regist/downPdf?registUid=" + registUid)

//退回
export const back = (params: {
    id: string
}) => http.get("registProjectBasicInfo/back", {
    params
})

// 进入初赛
export const gotoRoundo = (data) => http.post("regist/user/updateStep", data)

//获取推送数量
export const getPushCount = () => http.get<getPushCountType>("registSubmit/getPushCount",)

// 获取推送列表
export const pushList = (data: ListPagination & {
    data: PushListDataType
}) => http.post<ListType<any[]>>("registSubmit/list", data)

// 推送数量
export const pushNum = (num: number) => http.get<{
    application: any
    basice: any
    unit: any
}>("registSubmit/pushNum", {
    params: {
        num
    }
})


// 业务场景回显
export const registProjectBusinessScenesGetByUid = (query) => {
    return http.get('registProjectBusinessScenes/getByUid', { params: query })
}
export const registProjectBusinessScenesGetByUidOut = (query) => {
    return outHttp.get('registProjectBusinessScenes/getByUid', { params: query })
}

// 数据市场化回显
export const registProjectSurveyDataGetByUid = (query) => {
    return http.get('registProjectSurveyData/getByUid', { params: query })
}
export const registProjectSurveyDataGetByUidOut = (query) => {
    return outHttp.get('registProjectSurveyData/getByUid', { params: query })
}

// 应用场景回显
export const registProjectComprehensiveInfoGetByUid = (query) => {
    return http.get('registProjectComprehensiveInfo/getByUid', { params: query })
}
export const registProjectComprehensiveInfoGetByUidOut = (query) => {
    return outHttp.get('registProjectComprehensiveInfo/getByUid', { params: query })
}

export const registTeamInfoGEtByUid = (query) => {
    return http.get('registTeamInfo/getByUid', { params: query })
}
export const registTeamInfoGEtByUidOut = (query) => {
    return outHttp.get('registTeamInfo/getByUid', { params: query })
}

// 成员列表
export const registTeamMembersByUid = (query) => {
    return http.get('registTeamMembers/getByUid', { params: query })
}
export const registTeamMembersByUidOut = (query) => {
    return outHttp.get('registTeamMembers/getByUid', { params: query })
}

// 其他下拉列表
export const getDictByParentCode = (data: {
    dictCode: string
}) => http.get('sys/dict/getDictByParentCode', {
    params: data
})
export const getDictByParentCodeOut = (data: {
    dictCode: string
}) => outHttp.get('sys/dict/getDictByParentCode', {
    params: data
})

// 附件列表
export const listAttByUser = (query) => {
    return http.get('regist-att/listAttByUser', { params: query })
}
export const listAttByUserOut = (query) => {
    return outHttp.get('regist-att/listAttByUser', { params: query })
}

// 下载附件
export const downloadFile3 = (filePath: string) => http.getUpload2('file/downloadFile', { filePath })
export const downloadFile3Out = (filePath: string) => outHttp.getUpload2('file/downloadFile', { filePath })

/**
 * 推送数据
 */

export const postProject = (data: any) => http.post<{
    code: number
    data: string
    msg: string
    status: string
}>('registSubmit/postProject', data)
export const unitResult = (data: any) => http.post<{
    code: number
    data: string
    msg: string
    status: string
}>('registSubmit/unit-result', data)
export const appResult = (data: any) => http.post<{
    code: number
    data: string
    msg: string
    status: string
}>('registSubmit/app-result', data)

/**
 * 修改推送状态
 */
export const updataStatus = (data: string[]) => http.post('registSubmit/updataStatus', data)


// 撤销
export const resetStep = (data: {
    id: string
    step: '1' | '2'
}) => http.post("regist/user/resetStep", data)